package com.ihelp.rest.ueditor;

import java.io.InputStream;
import java.util.Properties;

/**
 * 上传文件路径配置文件
*      
* 类名称：FYKJProperties   
* 类描述：     
* 创建时间：2013-3-20 下午03:15:06    
* 备注：   
* @version
 */
public class UploadProperties {
	private Properties prop = null;
	private static UploadProperties instance = null;

	private UploadProperties() {
		prop = new Properties();
		try {
			String filename = "/file.properties"; 
			InputStream ins = UploadProperties.class.getResourceAsStream(filename);
			prop.load(ins);
			ins.close();
		} catch (Exception e) {
			throw new RuntimeException("加载file.properties文件时发生异常", e);
		}
	}

	public synchronized static UploadProperties getInstance(){
		if (instance == null) {
			instance = new UploadProperties();
		}
		return instance;
	}

	public String getProperty(String key) {
		return prop.getProperty(key);
	}
	
	public String getProperty(String key, boolean refresh) {
		if(!refresh){
			return getProperty(key);
		}
		prop = new Properties();
		try {
			String filename = "/file.properties"; 
			InputStream ins = UploadProperties.class.getResourceAsStream(filename);
			prop.load(ins);
			ins.close();
		} catch (Exception e) {
			throw new RuntimeException("加载file.properties文件时发生异常", e);
		}
		return prop.getProperty(key);
	}
}
